<template>
  <div class="sidebar">
    <div class="title">婚宴酒店关注排行</div>
    <ul class="hotel-list">
      <li
        class="hotel-li"
        @mouseenter="showInfo(i)"
        v-for="(item, i) in results"
        :key="i"
      >
        <router-link :to="`detail/${item.hid}`">
          <p>
            <span>{{ i + 1 }}.</span>
            {{ item.headline }}
          </p>
          <div class="hotel-info" :class="{ hideInfo: i == show }">
            <img :src="item.titlepicfile" :alt="item.headline" />
            <div>
              <p>桌数{{ item.max_table }}</p>
              <p>粉丝数{{ item.fans }}</p>
              <p>{{ item.genre }}</p>
            </div>
          </div>
        </router-link>
      </li>
    </ul>
  </div>
</template>
<script>
export default {
  data() {
    return {
      results: "",
      show: 0,
    };
  },
  methods: {
    LoadData() {
      this.axios.get("/hotel").then((res) => {
        this.results = res.data.results;
      });
    },
    showInfo(i) {
      this.show = i;
    },
  },
  mounted() {
    this.LoadData();
  },
};
</script>

<style>
.hideInfo {
  display: flex !important;
}

.sidebar {
  width: 210px;
  float: right;
}
.sidebar > .title {
  height: 40px;
  line-height: 40px;
  background-color: #fa4f5f;
  text-align: center;
  color: #fff;
  font-size: 18px;
}
.sidebar > .hotel-list {
  padding: 20px;
  border: 1px solid #e8e8e8;
}
.sidebar > .hotel-list > .hotel-li {
  margin-bottom: 18px;
}
.sidebar > .hotel-list > .hotel-li > a > p {
  color: #666;
  font-size: 14px;
  width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar > .hotel-list > .hotel-li > a:hover > p {
  color: #f83244;
}
.sidebar > .hotel-list img {
  width: 60px;
  height: 60px;
}
.sidebar > .hotel-list .hotel-info {
  display: none;
  margin-top: 15px;
}
.sidebar > .hotel-list .hotel-info div {
  font-size: 12px;
  color: #999;
  margin-left: 10px;
}
.sidebar > .hotel-list .hotel-info div > p {
  margin-bottom: 5px;
}
</style>